'use strict';

const Service = require('egg').Service;

class AddressService extends Service {
  async create(params) {
    const res = await this.app.mysql.insert('address', {
      ...params,
    });
    return res;
  }

  async update(params) {
    console.log(params);
    const res = await this.app.mysql.update('address', {
      ...params,
    });
    return res;
  }

  async select(user_id) {
    const res = await this.app.mysql.select('address', {
      where: {
        user_id,
      },
    });
    return res;
  }

  async get(id) {
    const res = await this.app.mysql.get('address', { id });
    return res;
  }

  async delete(id) {
    const res = await this.app.mysql.delete('address', { id });
    return res;
  }
}

module.exports = AddressService;
